﻿@model SCMS.UI.Models.AdvanceRequestModel
@{AjaxOptions ajaxOpts = new AjaxOptions
{
    UpdateTargetId = "R4ADiv",
    LoadingElementId = "loading",
    HttpMethod = "Post",
    Url = Url.Action("LoadRFADetails2/"+Model.Id)
};} 
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<div class="partialViewCard">
    <div class="partialViewCardHeader"><h3>@Model.RefNumber</h3></div>
    <br />
    <table width="98%" align="center" border="0" cellpadding="2" cellspacing="2" style=" border-bottom: 1px solid Grey;">
        <tr class="gridheader">
            <td colspan="3">
                Subject/Purpose
            </td>
        </tr>
        <tr>
            <td colspan="3">
                <b>@Model.Subject</b>
                @Html.HiddenFor(x => x.Subject)
            </td>
        </tr>
        <tr class="gridheader">
            <td>
                Payment To
            </td>
            <td>
                Payment Terms
            </td>
            <td>
                Payment Type
            </td>
        </tr>
        <tr>
            <td align="center">
                @Model.Payee
            </td>
            <td align="center">
                @Model.PaymentTerm
            </td>
            <td align="center">
                @Model.PaymentType
            </td>
        </tr>
        <tr class="gridheader">
            <td width="33%">
                Date
            </td>
            <td width="33%">
                Currency
            </td>
            <td width="34%">
                Total Payment
            </td>
        </tr>
        <tr>
            <td align="center">
                @Model.RequestDate.ToString("dd/MM/yyyy")
            </td>
            <td align="center">
                @Model.Currency
                @Html.HiddenFor(x => x.CurrencyId, new { @id = "currencyId"})
            </td>
            <td align="center">
                <b>@Model.TotalAdvance.ToString("#,##0.00")</b>
                @Html.HiddenFor(m => m.TotalAdvance, new { @id = "totalAdvance"})
            </td>
        </tr>
    </table>
    <br />    
        
    <table class="cardTable" cellpadding="2">
        <tr class="gridheader">
            <th colspan="6" align="center">Payment Details</th>
        </tr>
        <tr>
            <td colspan="6">
                @Ajax.ActionLink("Add Payment Detail", "CreateRFADetail", new AjaxOptions
                {
                    UpdateTargetId = "popup-page",
                    LoadingElementId = "popup-loading",
                    Url = Url.Action("CreateRFADetail/" + Model.Id),
                    OnBegin = "ShowDialogue('Add Payment Detail')",
                    OnSuccess = "CenterPopup();ClearForm();"
                })
            </td>
        </tr>
        @if (Model.PaymentDetails.Count > 0)
        { 
            <tr class="gridheader">
                <th align="center">Request For</th>
                <th align="center">Description</th>
                <th align="center">Project No.</th>
                <th align="center">Budget Line</th>
                <th align="center">Amount</th>
                <th align="center">Manage</th>
            </tr>
            foreach (var detail in Model.PaymentDetails)
            { 
                <tr>
                    <td>@detail.AdvanceOption</td>
                    <td>@detail.Description</td>
                    <td>@detail.ProjectNo</td>
                    <td>@detail.BudgetLine</td>
                    <td align="right">@detail.Amount.ToString("#,##0.00")</td>
                    <td>
                        @Ajax.ActionLink("Edit", "EditRFADetail", new { id = "EditRFADetail" }, new AjaxOptions
                        {
                            UpdateTargetId = "popup-page",
                            LoadingElementId = "popup-loading",
                            Url = Url.Action("EditRFADetail/" + detail.Id),
                            OnBegin = "ShowDialogue('Edit:: " + detail.AdvanceOption + "')",
                            OnSuccess = "clenaRFANumbers"
                        })
                        &nbsp; | &nbsp;
                        @Ajax.ActionLink("Remove", "DeleteRFADetail", new { id = "DeleteRFADetail" }, new AjaxOptions
                        {
                            UpdateTargetId = "R4ADiv",
                            LoadingElementId = "loading",
                            Url = Url.Action("DeleteRFADetail/" + detail.Id),
                            Confirm = "Remove Payment Detail?"
                        })
                    </td>
                </tr>
            }
        }
    </table>
    <br /> 
        
    <table width="98%" cellpadding="0" cellspacing="0" align="center">
        <tr>
            <td width="50%"><input type="button" class="btn green" value="<< Prev" onclick="sendRequest('/Request4Advance/EditRFA/@Model.Id', 'R4ADiv', 'loading')" /></td>
            <td width="50%" align="right"><input type="button" class="btn green" value="Next >>" onclick="checkRFADetails('/Request4Advance/LoadRFADetails2/@Model.Id', 'R4ADiv', 'loading')" /></td>
        </tr>
    </table>  
</div>

